package org.example.elm_xiangmu.mapper;

import org.apache.ibatis.annotations.*;
import org.example.elm_xiangmu.po.DeliveryAddress;

import java.util.List;

@Mapper
public interface DeliveryAddressMapper {
    @Select("select * from deliveryaddress where userId = #{userId}")
    List<DeliveryAddress> listDeliveryAddressByUserId(String userId);

    @Select("select * from deliveryaddress where daId = #{daId}")
    List<DeliveryAddress> getDeliveryAddressById(String daId);

    @Insert("insert into deliveryaddress (contactName,contactSex,contactTel,address,userId) values (#{contactName},#{contactSex},#{contactTel},#{address},#{userId})")
    void saveDeliveryAddress(DeliveryAddress deliveryAddress);

    @Update("update deliveryaddress set contactName = #{contactName},contactSex = #{contactSex},contactTel = #{contactTel},address = #{address},userId = #{userId} where daId = #{daId}")
    void updateDeliveryAddress(DeliveryAddress deliveryAddress);

    @Delete("delete from deliveryaddress where daId = #{daId}")
    void removeDeliveryAddress(Integer daId);
}
